<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ include file="/wesite/view/common/base.jsp" %>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>选择优惠券</title>
    <%@ include file="/wesite/view/common/common.jsp" %>
</head>
<body>
<div class="uses-discount-list">
    <ul>
        <c:forEach var="info" items="${list }">
            <li class="coupon">
                <div class="selectbox"><input type="radio" name="discount" value="${info.id}"></div>
                <div class="choose-coupons-item">
                        <%--<strong>券</strong>--%>
                    <div class="white">
                        <span class="dot dot1"></span>
                        <span class="dot dot2"></span>
                        <span class="white-hr"></span>
                    </div>
                    <div class="vouchers-lines"><span>￥<em class="offermoney">${info.offer_money}</em></span></div>
                    <div class="vouvhers-txt">
                        <p class="txt-limit">购物满${info.min_money}元使用</p>
                        <p class="txt-time-end">有效日期至${info.enddate }</p>
                    </div>
                </div>
            </li>
        </c:forEach>
    </ul>
</div>
<div><input type="button" class="coupon-determine" onclick="selectCoupon()" value="确认"></div>
<input type="hidden" name="code" value="${code}">
<input type="hidden" name="orderbz" value="${orderbz}">
<input type="hidden" name="paytype" value="${paytype}">
</body>
<script type="text/javascript">
    function selectCoupon() {
        var checked = $("input[name='discount']:checked");
        var couponId = 0;
        var offerMoney = 0;
        if(checked.length == 1){
            couponId = checked.val();
            offerMoney = checked.parents(".coupon").find(".offermoney").text();
        }
        $w.httpRequest({
            url: "${ctx}/we/coupon/" + $("[name='code']").val(),
            method: "post",
            data: {
                "_method": "put",
                "couponId": couponId,
                "offerMoney": offerMoney,
                "bz": $("[name='orderbz']").val(),
                "paytype": $("[name='paytype']").val()
            },
            ok: function (ret) {
                window.location.href = ret.Data;
            }
        })
    }
    apiready = function () {
        api.parseTapmode();
    }
</script>
</html>